#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import datetime


# the worest --> 30+ seconds
def prime1():
    count = 0
    for i in range(2, 100001):
        for x in range(2, i):
            if i % x == 0:
                break
        else:
            count += 1
    return count


# the mid --> 4 seconds (1000000)
def prime2():
    start = datetime.datetime.now()
    count = 0
    for i in range(2, 1000001):
        for x in range(2, int(i**0.5) + 1):
            if i % x == 0:
                break
        else:
            count += 1
    delta = (datetime.datetime.now() - start).total_seconds()
    print(delta)
    return count


# the best --> 2 seconds (1000000)
def prime3():
    start = datetime.datetime.now()
    count = 1
    for i in range(3, 100001, 2):
        for x in range(3, int(i**0.5) + 1, 2):
            if i % x == 0:
                break
        else:
            count += 1
    delta = (datetime.datetime.now() - start).total_seconds()
    print(delta)
    return count


# the best --> 2 second (1000000)
def prime4():
    count = 1
    start = datetime.datetime.now()
    for i in range(3, 100001, 2):
        if i > 10 and i % 5 == 0:
            continue
        for x in range(3, int(i**0.5) + 1, 2):
            if i % x == 0:
                break
        else:
            count += 1
    delta = (datetime.datetime.now() - start).total_seconds()
    print(delta)
    return count


print(prime3())
print(prime4())
